package cn.lls.controller.employee;


import cn.lls.base.result.R;
import cn.lls.entity.sys.RoleEntity;
import cn.lls.service.IRoleService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotEmpty;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 划水艺术家
 * @since 2022-11-15
 */
@RestController
@RequestMapping("/emp/role")
@Slf4j
public class EMPRoleController {

    @Autowired
    private IRoleService roleService;


    @GetMapping("/select/{departmentId}")
    @ApiOperation(value = "根据departmentId查询角色信息", notes = "根据departmentId查询角色信息", response = R.class, httpMethod = "GET")
    public R getRoleSByDepartmentId(@ApiParam(required = true, value = "角色Id")
                               @PathVariable("departmentId")
                               @NotEmpty(message = "部门Id不能为空") Long departmentId){

        LambdaQueryWrapper<RoleEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(RoleEntity::getDepartmentId, departmentId);
        return R.success(roleService.list(queryWrapper));
    }


}

